package com.lghdb.driver_client.data;

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by lghdb on 2018/3/23.
 */

public class DataConfig {

    private static DataConfig config = new DataConfig();
    private static String url = "http://localhost:8069";
    public static String db = "localodoo10";


    private DataConfig(){}

    public static DataConfig getConfig(){
        return config;
    }
    private XmlRpcClient getClient(String obj) throws MalformedURLException{
        XmlRpcClient client = new XmlRpcClient();
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(new URL(String.format("%s/xmlrpc/2/%s", url,obj)));
        client.setConfig(config);
        return client;
    }
    public XmlRpcClient getCommon() throws MalformedURLException{
        return getClient("common");
    }
    public XmlRpcClient getModel() throws MalformedURLException{
        return getClient("object");
    }
}
